package com.client.mapper;

import com.Emplyment.dto.ClientUserDto;
import com.Emplyment.dto.ReUserPasswordDto;
import com.Emplyment.entity.InterView;
import com.Emplyment.entity.UserMessage;
import com.Emplyment.vo.*;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserCenterMapper {

    @Select("select companyId from company_collect where username = #{username}")
    List<Integer> getCollectCompanyId(String username);

    List<ArticleVo> getCompany(List<Integer> ids);

    @Select("select quetionbank_id from questionbank_collect where username = #{username}")
    List<Integer> getCollectQuestionId(String username);

    List<QuestionBankVo> getQuestion(List<Integer> ids);

    @Delete("delete from company_collect where username = #{username} and companyId = #{companyId}")
    void canalUserCompany(String username, Integer companyId);

    @Update("update article set collect_number = collect_number - 1 where id = #{companyId}")
    void reduceCompanyCollect(Integer companyId);

    @Delete("delete from questionbank_collect where username = #{username} and quetionbank_id = #{questionId}")
    void canalUserQuestion(String username, Integer questionId);

    @Update("update question_bank set collect_num = collect_num - 1 where id = #{questionId}")
    void reduceQuestionCollect(Integer questionId);

    void updateUser(ClientUserDto clientUserDto);

    @Update("update client_user set userPic = #{avatarUrl} where username = #{username}")
    void updateAvatar(String username,String avatarUrl);

    @Update("update client_user set password = #{newPassword} where username = #{username}")
    void resetPassword(ReUserPasswordDto reUserPasswordDto);

    @Select("select * from client_user where username = #{username}")
    UserMessage checkUsername(String username);

    @Select("select * from interview where author = #{username}")
    List<InterViewVo> getInterviewByUser(String username);

    @Delete("delete from interview where interviewId = #{interviewId}")
    void deleteInterview(Integer interviewId);

    @Delete("delete from comment where interviewId = #{interviewId}")
    void deleteComment(Integer interviewId);

    @Select("select * from comment where author = #{username}")
    List<CommentVo> getCommentByUser(String username);

    @Select("select * from interview where interviewId = #{interviewId}")
    InterView getInterviewById(int interviewId);

    @Delete("delete from comment where author = #{username} and interviewId = #{interviewId} and id = #{commentId}")
    void deleteCommentByUser(String username, Integer interviewId, Integer commentId);
}
